package com.a16.yuejian.yuejian.activity;

import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.TextView;
import android.widget.Toast;

import com.a16.yuejian.yuejian.R;
import com.a16.yuejian.yuejian.javabean.Order;
import com.a16.yuejian.yuejian.listener.OrderListener;
import com.a16.yuejian.yuejian.model.ActivityModel;

public class OrderActivity extends AppCompatActivity {
    private TextView or_name,or_ordernum,or_time,or_username,or_tel,or_num,or_price;
    private SharedPreferences sp;
    private Intent intent;

    OrderListener orderListener = new OrderListener() {
        @Override
        public void onResponse(Order info) {
            or_name.setText(info.getOrdername());
            or_ordernum.setText(info.getOrdernum());
            or_time.setText(info.getTime());
            or_username.setText(info.getUsername());
            or_tel.setText(info.getUserphone());
            or_num.setText(info.getNum());
            or_price.setText(info.getPrice());
        }

        @Override
        public void onFail() {

        }
    };

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_order);
        initViews();
        ActivityModel activityModel = new ActivityModel();
        activityModel.getOrder(sp.getString("uid",""),getIntent().getStringExtra("ordernum"),orderListener);
    }

    private void initViews() {
        or_name = (TextView)findViewById(R.id.or_name);
        or_ordernum = (TextView)findViewById(R.id.or_ordernum);
        or_time = (TextView)findViewById(R.id.or_time);
        or_username = (TextView)findViewById(R.id.or_username);
        or_tel = (TextView)findViewById(R.id.or_tel);
        or_num = (TextView)findViewById(R.id.or_num);
        or_price = (TextView)findViewById(R.id.or_price);
        sp = getSharedPreferences("userinfo", Context.MODE_PRIVATE);
    }
}
